package com.hexiang.err.handler;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.client.RestClientException;

@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理http请求返回异常
     *
     */
    @ExceptionHandler(RestClientException.class)
    public ResponseEntity<String> throwRestException(RestClientException restClientException) {
        return new ResponseEntity<String>(restClientException.getMessage(), HttpStatus.BAD_REQUEST);
    }
}